package com.icss.ah.sale.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class SaleOrderListService {
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;
	private final Logger errlog = Logger.getLogger("E");
	private final Logger infolog = Logger.getLogger("I");

	/**
	 * 获取销售订单流水列表
	 * 
	 * @param map
	 * @return
	 */
	public List<Map<String, Object>> getSaleOrderList(Map<String, String> map) {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		try {
			list = sqlSessionTemplate.selectList(
					"SaleOrderListBean.getSaleOrderList", map);
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("SaleOrderListService|getSaleOrderList", e);
		}
		return list;
	}

	/**
	 * 获取销售订单流水列表总数
	 * @param map
	 * @return
	 */
	public Long getSaleOrderTotal(Map<String, String> map) {
		Long count = 0L;
		try {
			count = sqlSessionTemplate.selectOne("SaleOrderListBean.getSaleOrderTotal",map);
			infolog.info("SaleOrderListService|getSaleOrderTotal|count: "+count);
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("SaleOrderListService|getSaleOrderTotal", e);
		}
		return count;
	}

}
